<cpanel include="../../../config.php">

<?

/***************************************************************************
 *                                 file_permissions.php
 *                            -------------------
 *   Begin                : Thursday, April 16, 2005
 *   Copyright            : (C) 2005 Point and Code
 *   Domain               : http://www.pointandcode.com/
 *   Email                : support@pointandcode.com
 *   Version              : 1.0.0
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

$html_root_path = '../../../';
$page_title = "New File";
include $root_path.'common.php';
include $root_path.'page_header.php';

$template->set_filenames(array(
	'body' => $root_path.$template_path.'files/manager/file_permissions.tpl')
);

$directory = <<<EOFpacman
<cpanel print="$FORM{'dir'}">
EOFpacman;

$file = <<<EOFpacman
<cpanel print="$FORM{'file'}">
EOFpacman;

$s_hidden_vars = "
<input type=\"hidden\" name=\"dir\" value=\"".$directory."\">
<input type=\"hidden\" name=\"file\" value=\"".$file."\">
";


$permission_junk = <<<EOFpacman
<cpanel Fileman="showperm($FORM{'dir'},$FORM{'file'})">
EOFpacman;

$permission_array = explode('<input ', $permission_junk);

// Let's sort out the permission array...
if (strstr($permission_array[1], 'checked'))
{
	$user_read_checked = 1;
};
if (strstr($permission_array[2], 'checked'))
{
	$group_read_checked = 1;
};
if (strstr($permission_array[3], 'checked'))
{
	$world_read_checked = 1;
};
if (strstr($permission_array[4], 'checked'))
{
	$user_write_checked = 1;
};
if (strstr($permission_array[5], 'checked'))
{
	$group_write_checked = 1;
};
if (strstr($permission_array[6], 'checked'))
{
	$world_write_checked = 1;
};
if (strstr($permission_array[7], 'checked'))
{
	$user_execute_checked = 1;
};
if (strstr($permission_array[8], 'checked'))
{
	$group_execute_checked = 1;
};
if (strstr($permission_array[9], 'checked'))
{
	$world_execute_checked = 1;
};


$user_permission = $user_read_checked * 4 + $user_write_checked * 2 + $user_execute_checked * 1;
$group_permission = $group_read_checked * 4 + $group_write_checked * 2 + $group_execute_checked * 1;
$world_permission = $world_read_checked * 4 + $world_write_checked * 2 + $world_execute_checked * 1;

$template->assign_vars(array(
	'DIRECTORY' => $directory,
	'FILE' => $file,

	'USER_READ_CHECKED' => (($user_read_checked == 1) ? 'checked="checked"' : ''),
	'USER_WRITE_CHECKED' => (($user_write_checked == 1) ? 'checked="checked"' : ''),
	'USER_EXECUTE_CHECKED' => (($user_execute_checked == 1) ? 'checked="checked"' : ''),
	'GROUP_READ_CHECKED' => (($group_read_checked == 1) ? 'checked="checked"' : ''),
	'GROUP_WRITE_CHECKED' => (($group_write_checked == 1) ? 'checked="checked"' : ''),
	'GROUP_EXECUTE_CHECKED' => (($group_execute_checked == 1) ? 'checked="checked"' : ''),
	'WORLD_READ_CHECKED' => (($world_read_checked == 1) ? 'checked="checked"' : ''),
	'WORLD_WRITE_CHECKED' => (($world_write_checked == 1) ? 'checked="checked"' : ''),
	'WORLD_EXECUTE_CHECKED' => (($world_execute_checked == 1) ? 'checked="checked"' : ''),

	'USER_PERMISSION' => $user_permission,
	'GROUP_PERMISSION' => $group_permission,
	'WORLD_PERMISSION' => $world_permission,

	'S_ACTION' => 'file_permissions_done.php',
	'S_HIDDEN_VARS' => $s_hidden_vars,
));


//
// Woohoo! All done!
//
$template->pparse('body');




include $root_path.'page_tail.php';




?>

